package ${package}.${moduleName}.controller;

import ${package}.${moduleName}.entity.${ClassName};
import ${package}.${moduleName}.service.${ClassName}Service;
import ${package}.${moduleName}.query.${ClassName}Query;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.source.common.page.PageOutput;
import com.source.common.result.Response;

import java.util.List;
import java.util.Arrays;

/**
* ${tableComment}
*
* @author ${author}
* @since ${version} ${date}
*/
@RestController
@Api(value = "${ClassName}Controller", tags = "${tableComment}")
@RequiredArgsConstructor
@Slf4j
@RequestMapping("${moduleName}/${functionName}")
public class ${ClassName}Controller {

    private final ${ClassName}Service ${className}Service;

    /**
     * 根据条件查询记录并分页
     *
     * @param query 查询对象
     */
    @ApiOperation(value = "分页查询")
    @PostMapping("/getPaged")
    public Response<PageOutput<${ClassName}>> getTeamMsgPaged(@RequestBody ${ClassName}Query query) {
        return Response.ok(${className}Service.get${ClassName}AndPage(query));
    }

    /**
     * 根据条件查询记录不分页
     *
     * @param query 查询对象
     */
    @ApiOperation(value = "所有数据")
    @PostMapping("/getList")
    public Response<List<${ClassName}>> get${ClassName}AllList(@RequestBody ${ClassName}Query query) {
        return Response.ok(${className}Service.get${ClassName}s(query));
    }

    /**
    * 获取单条数据信息
    */
    @ApiOperation(value = "获取单条数据信息")
    @PostMapping("/getInfo/{id}")
    public Response info(@PathVariable("id") String id){
        return Response.ok(${className}Service.getById(id));
    }

    /**
    * 新增
    */
    @ApiOperation(value = "新增")
    @PostMapping("/insert")
    public Response insert(@RequestBody ${ClassName} ${className}){
        return Response.ok(${className}Service.save(${className}));
    }

    /**
    * 修改
    */
    @ApiOperation(value = "修改")
    @PostMapping("/update")
    public Response update(@RequestBody ${ClassName} ${className}){
        return Response.ok(${className}Service.updateById(${className}));
    }

    /**
    * 删除
    */
    @ApiOperation(value = "删除")
    @PostMapping("/delete/{ids}")
    public Response delete(@PathVariable("ids") String ids){
        return Response.ok(${className}Service.removeByIds(Arrays.asList(ids.split(","))));
    }



}